﻿using ConfExpert.Utility;
using DevExpress.XtraEditors.Repository;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tailord
{
    public partial class MusteriEkle : XPopupForm
    {
        public MusteriEkle()
        {
            InitializeComponent();
        }

        private void MusteriEkle_Load(object sender, EventArgs e)
        {
            ShowOnlyBar();
            gleSegment.Properties.Assign(riSegment);

        }
        
        private void bbiKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (txtAd.Text == "")
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Müşteri ismi girmelisiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtTelefon.Text == "")
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Telefon girmelisiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtAdres.Text == "")
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Adres girmelisiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DataTable dtMusteri = AppSession.DataManager.ExecuteDataTable("SaveCustomerByYP", gleSegment.EditValue, txtAd.Text, txtEPosta.Text, dateDogumTarihi.EditValue, txtTelefon.Text, txtAdres.Text, txtSehir.Text, txtUlke.Text, txtNot.Text, WhoAmI);
            drMusteri = dtMusteri.Rows[0];
            this.DialogResult = DialogResult.OK;
        }

        public DataRow drMusteri { get; set; }
        public RepositoryItemGridLookUpEdit riSegment
        {
            get
            {
                RepositoryItemGridLookUpEdit ri = GetCustomRI("SEGMENT", false, "NEW", "E DAVET", "BRONZE", "SILVER", "GOLD", "PLATINIUM");
                return ri;
            }
        }
    }
}
